package io.jt808.proto.req;

import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

/**
 * 提问应答
 */
@Proto("0302")
@Data
public class JT0302 implements IProto {
    /**
     * 对应的提问下发消息的流水号
     */
    private int responseMessageSerialNo;
    /**
     * 提问下发中附带的答案ID
     */
    private short answerId;


    public byte[] writeToBytes() {
        AutoBuffer buff = new AutoBuffer();
        buff.writeShort(responseMessageSerialNo);
        buff.writeByte(answerId);
        return buff.array();

    }

    public void readFromBuf(AutoBuffer buffer) {
        responseMessageSerialNo = buffer.readUnsignedShort();
        answerId = buffer.readUnsignedByte();
    }

//    public static void main(String[] args) {
//        byte[] bytes = new byte[]{
//                0x00, 0x01,
//                0x03
//        };
//        JT0302 jt0302 = new JT0302();
//        jt0302.readFromBuf(new AutoBuffer(bytes));
//        System.out.println(new String(bytes).equals(new String(jt0302.writeToBytes())));
//    }
}